|
|
|
|
|
|
|
'Open the text file with team names
If sLeague = "National League" Then
Open App Path & "\NLEAGUE.TXT" For Input As #1
Else
Open App Path & "\ALEAGUE.TXT" For Input As #1
End If
'Add the 5 EAST teams
For nCounter = 1 To 5
Line Input #1, sTemp
Set tempNode = tv1.Nodes.Add("E", tvwChild, "E" & nCounter, sTemp)
Next nCounter
tempNode.EnsureVisible
'Add the 5 CENTRAL teams
For nCounter = 1 To 5
Line Input #1, sTemp
Set tempNode = tv1.Nodes.Add("C", tvwChild, "C" & nCounter, sTemp)
Next nCounter
tempNode.EnsureVisible
'Add the 4 WEST teams
For nCounter = 1 To 4
Line Input #1, sTemp
Set tempNode = tv1.Nodes.Add("W", tvwChild, "W" & nCounter, sTemp)
Next nCounter
tempNode.EnsureVisible
'Close the Input file
Close #1
'Set the Desired style
tv1.Style = tvwTreelinesText
tv1.BorderStyle = vbFixedSingle
'Set the TreeView control on top
tv1.ZOrder 0
End Sub |
|
|
|
|
|
|
|
|
Notice that the relationships in the tree view are defined as a node is added. The Add method's first parameter lists a "relative" node and the second parameter lists the relationship to that relative. The constant tvwChild indicates that the new node is a child of the relative node. |
|
|
|
|
|
|
|
|
Taking Action in the Program |
|
|
|
|
|
|
|
|
Now, you are ready to return to the topic of the TabStrip control and set up the form's Load event. When the form first appears, you probably want it to show something, so you can call the DisplayLeague procedure to display the American League teams. The code for the Load event is shown in Listing 12.4. At this point, you can run your program, and the American League teams are displayed. However, clicking the TabStrip has no effect on the TreeView because you have not yet added the necessary code to the TabStrip's Click event. This code, also shown in Listing 12.4, calls the DisplayLeague procedure with the name of the desired league. |
|
|
|
|
|